

// components/player-tools/index.ts
const app = getApp();

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      value: "古剑奇谭"
    },
    description: {
      type: String,
      value: "古剑奇谭古剑奇谭古剑奇谭古剑奇谭古剑奇谭古剑奇谭"
    },
    heatNumber: {
      type: String,
      value: "1000+"
    },
    toolsPubData: {
      type: Object,
      value: {
        // like: 0,
        // star: 0,
        // forword: 0,
        // comment: 0,
        // stay: 0,
        // read: 0
      }
    },
    toolsPubState: {
      type: Object,
      value: {}
    },
    videoDetail:{
      type:Object,
      value:{}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    activeNames: ["0"],
    isCollapseOpen: false,
    animationData: {},
  },

  lifetimes: {
    ready() {
      this.arrowRotate()
    }
  },

  /**
   * 组件的方法列表
   */

  methods: {

    arrowRotate() {
      this.setData({
        isCollapseOpen: !this.data.isCollapseOpen
      });
      this.triggerEvent("arrowChange", this.data.isCollapseOpen);

      const animation = wx.createAnimation({ duration: 220 });
      let angle = this.data.isCollapseOpen ? -180 : 0;
      animation.rotate(angle).step();
      this.setData({
        animationData: animation.export()
      })
    },
    // 分享
    onShare() {      
      this.triggerEvent('tapShare', {})
    },
    // 收藏
    tapCollect() {
      let addOrdel = !this.properties.toolsPubState.star;
      this.triggerEvent('collect', addOrdel)
    },
    // 点赞
    tapLike() {
      let addOrdel = !this.properties.toolsPubState.like;
      this.triggerEvent('like', addOrdel)
    },
    // 弹幕
    showBarrage() {
      this.triggerEvent('tapBarrage', {})
    },
    videoShort() {
      this.triggerEvent('videoShort', {})
    }
  },
})
